package cn.edu.neusoft.practice.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import cn.edu.neusoft.practice.po.Special;
import cn.edu.neusoft.practice.po.User;

//替代了DAO and .xml 需要SQL能力
//让mapper具有对简单的单表来直接进行映射，直接进行CRUD操作的能力，以简化我们的一些工作任务。


@Mapper
public interface UserMapper extends BaseMapper<User>{
	
	@Update("update user set password=#{password} where user_id=#{userId}")
	public int updatepassword(User e);
	
	@Select("select u.* from user u where u.user_name=#{userName} and password=#{password} and user_role=#{userRole}")
	  User checkLogin(User user);//登录
	
	@Select("select u.* from user u where u.user_name=#{userName} or u.telephone=#{telephone}")
	User checkUserName(User user);//注册
	
	@Select("update user set special=1 where user_id=#{userId}")
	List<User> updateSpecial(int userId);//只改Special
	
	@Select("insert into special(user_id,user_name,real_name,delete_flag) values(#{userId},#{userName},#{realName},0)")
	List<Special> jiaSpecial(User u);//加
	

}
